//
//  JSSEmoticonModel.swift
//  WeiBoItem
//
//  Created by jss on 16/4/27.
//  Copyright © 2016年 jss. All rights reserved.
//

import UIKit

class JSSEmoticonModel: NSObject,NSCoding {

    //表情的描述字符串
    var chs: String?
    
    //emoji表情的code
    var code:String?
    
    //如果是1 代表是Emoji表情 是0 代表是图片表情
    var type: String?
    
    //图片表情对应的图片名字
    var png: String?
    
    //当前表情属于哪个文件夹
    var folderName: String?
    
    init(dict:[String:AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    //归档
    func encodeWithCoder(aCoder: NSCoder) {
        
        
        aCoder.encodeObject(chs, forKey: "chs")
        aCoder.encodeObject(code, forKey: "code")
        aCoder.encodeObject(type, forKey: "type")
        aCoder.encodeObject(png, forKey: "png")
        aCoder.encodeObject(folderName, forKey: "folderName")
    }
    
    
    //解档
     required init?(coder aDecoder: NSCoder) {
       
        chs = aDecoder.decodeObjectForKey("chs") as? String
        code = aDecoder.decodeObjectForKey("code") as? String
        type = aDecoder.decodeObjectForKey("type") as? String
        png = aDecoder.decodeObjectForKey("png") as? String
        folderName = aDecoder.decodeObjectForKey("folderName") as? String
        
        
    }
    
    //为了看到模型里面显示的数据 重写description方法 这里没有提示 只能手打
    override var description:String {
    
    let keys = ["chs","code","type"]
        
        return dictionaryWithValuesForKeys(keys).description
    
    }
}
